#include <stdio.h>

int main(void)
{
    printf("method 1:\n");
    {
        int a = 0x12345678;
        if (*((char*)&a) == 0x12)
            printf("\tBig endian CPU\n");
        else
            printf("\tLittle endian CPU\n");
    }

    printf("method 2:\n");
    {
        char a[] = {0x12, 0x34, 0x56, 0x78};
        if (*(int *)a == 0x12345678) {
            printf("\tBig endian CPU\n");
        } else if (*(int *)a == 0x78563412) {
            printf("\tLittle endian CPU\n");
        }
    }
    return 0;
}